
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>消息提示 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="CONFIRM.html" />
    
    
    <link rel="prev" href="CHECKBOX.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="BUTTON.html">
            
                <a href="BUTTON.html">
            
                    
                    按钮
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="PAGE.html">
            
                <a href="PAGE.html">
            
                    
                    分页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="DROP.html">
            
                <a href="DROP.html">
            
                    
                    下拉按钮
            
                </a>
            

            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="CHECKBOX.html">
            
                <a href="CHECKBOX.html">
            
                    
                    单选与多选
            
                </a>
            

            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter active" data-level="4.1" data-path="TOAST.html">
            
                <a href="TOAST.html">
            
                    
                    消息提示
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="CONFIRM.html">
            
                <a href="CONFIRM.html">
            
                    
                    确认对话框
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="MODAL.html">
            
                <a href="MODAL.html">
            
                    
                    模态框
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="WINDOW.html">
            
                <a href="WINDOW.html">
            
                    
                    窗口
            
                </a>
            

            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="ECHARTS.html">
            
                <a href="ECHARTS.html">
            
                    
                    百度图表
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >消息提示</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x6D88;&#x606F;&#x63D0;&#x793A;">&#x6D88;&#x606F;&#x63D0;&#x793A;</h1>
<p>&#x901A;&#x5E38;&#x60C5;&#x51B5;&#x4E0B;&#x5728;&#x6267;&#x884C;&#x4E00;&#x4E9B;&#x64CD;&#x4F5C;&#x65F6;&#xFF0C;&#x5BF9;&#x6BCF;&#x6B21;&#x64CD;&#x4F5C;&#x7ED3;&#x679C;&#x90FD;&#x8981;&#x7ED9;&#x4E88;&#x63D0;&#x793A;&#x4FE1;&#x606F;&#xFF0C;&#x5982;&#x5220;&#x9664;&#x64CD;&#x4F5C;&#x3002;</p>
<h2 id="&#x5BFC;&#x5165;&#x76F8;&#x5173;&#x6A21;&#x5757;">&#x5BFC;&#x5165;&#x76F8;&#x5173;&#x6A21;&#x5757;</h2>
<p>&#x9700;&#x8981;&#x5728;&#x6839;&#x6A21;&#x5757;&#x5BFC;&#x5165;&#x6A21;&#x5757;ToastModule&#xFF0C;&#x4E00;&#x822C;&#x7684;&#x9879;&#x76EE;&#x5DF2;&#x7ECF;&#x5BFC;&#x5165;&#x4E86;&#xFF08;<strong>&#x5728;&#x5176;&#x5B83;&#x4EFB;&#x4F55;&#x6A21;&#x5757;&#x4E2D;&#x4E0D;&#x9700;&#x8981;&#x5BFC;&#x5165;&#x4E86;&#xFF01;</strong>&#xFF09;</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> { NgModule } from <span class="hljs-string">&apos;@angular/core&apos;</span>;
<span class="hljs-keyword">import</span> { AppRoutingModule } from <span class="hljs-string">&apos;./app.routing&apos;</span>;
<span class="hljs-keyword">import</span> { AppComponent } from <span class="hljs-string">&apos;./app.component&apos;</span>;

<span class="hljs-comment">// &#x9700;&#x8981;&#x4F7F;&#x7528;ToastModule&#x6A21;&#x5757;</span>
<span class="hljs-keyword">import</span> {ToastModule} from <span class="hljs-string">&apos;ng-tools-ui&apos;</span>;

@NgModule({
    declarations: [AppComponent],
    imports: [
        ...
        ToastModule.forRoot({
            <span class="hljs-comment">// &#x6D88;&#x606F;&#x63D0;&#x793A;&#x51FA;&#x73B0;&#x4F4D;&#x7F6E;&#xFF08;&#x53F3;&#x4E0B;&#xFF09;</span>
            position: <span class="hljs-string">&apos;ts-bottom ts-right&apos;</span>, 
            <span class="hljs-comment">// &#x6D88;&#x606F;&#x663E;&#x793A;&#x65F6;&#x95F4;4&#x79D2;</span>
            timeout: <span class="hljs-number">4000</span>, 
            <span class="hljs-comment">// &#x540C;&#x65F6;&#x51FA;&#x73B0;&#x7684;&#x6D88;&#x606F;&#x6570;&#x91CF;4&#x6761;</span>
            maxLength: <span class="hljs-number">4</span> 
        }),
        ...
        AppRoutingModule,
    ],
    bootstrap: [AppComponent]
})
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> AppModule { }
</code></pre>
<h2 id="&#x4F7F;&#x7528;toastservice&#x663E;&#x793A;&#x63D0;&#x793A;">&#x4F7F;&#x7528;ToastService&#x663E;&#x793A;&#x63D0;&#x793A;</h2>
<p>&#x5728;&#x9700;&#x8981;&#x7528;&#x5230;&#x7684;&#x9875;&#x9762;&#x7EC4;&#x4EF6;&#x4E2D;&#x6CE8;&#x5165;&#x6D88;&#x606F;&#x670D;&#x52A1;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E86;</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> { Component } from <span class="hljs-string">&apos;@angular/core&apos;</span>;
<span class="hljs-comment">// &#x5F15;&#x5165;&#x6D88;&#x606F;&#x670D;&#x52A1;</span>
<span class="hljs-keyword">import</span> { ToastService } from <span class="hljs-string">&apos;ng-tools-ui&apos;</span>;

@Component({
    templateUrl: <span class="hljs-string">&apos;./example.component.html&apos;</span>,
})
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> ExampleComponent {

    <span class="hljs-keyword">constructor</span>(
        // &#x6CE8;&#x5165;&#x6D88;&#x606F;&#x670D;&#x52A1;
        private toast: ToastService,
    ) { }

    showMessage(){
        <span class="hljs-keyword">this</span>.toast.info(<span class="hljs-string">`&#x63D0;&#x793A;`</span>, <span class="hljs-string">&apos;&#x8FD9;&#x662F;&#x4E00;&#x6761;&#x63D0;&#x793A;&#x4FE1;&#x606F;...&apos;</span>);
    }
}
</code></pre>
<h2 id="toastservice-&#x53C2;&#x8003;">ToastService &#x53C2;&#x8003;</h2>
<h3 id="&#x65B9;&#x6CD5;">&#x65B9;&#x6CD5;</h3>
<p>1.<strong>info</strong>(title: string, message: string, timer?: number)</p>
<blockquote>
<p>&#x663E;&#x793A;&#x4E00;&#x6761;&#x4FE1;&#x606F;&#x6D88;&#x606F;</p>
</blockquote>
<table>
<thead>
<tr>
<th>&#x53C2;&#x6570;</th>
<th>&#x7C7B;&#x578B;</th>
<th>&#x8BE6;&#x60C5;</th>
</tr>
</thead>
<tbody>
<tr>
<td>title</td>
<td>string</td>
<td>&#x6D88;&#x606F;&#x6807;&#x9898;</td>
</tr>
<tr>
<td>message</td>
<td>string</td>
<td>&#x6D88;&#x606F;&#x5185;&#x5BB9;</td>
</tr>
<tr>
<td>timer</td>
<td>number</td>
<td>&#x6D88;&#x606F;&#x663E;&#x793A;&#x65F6;&#x95F4;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x586B;&#x90A3;&#x4E48;&#x9ED8;&#x8BA4;&#x91C7;&#x7528;&#x5168;&#x5C40;&#x914D;&#x7F6E;&#x7684;forRoot&#x4E2D;&#x8BBE;&#x7F6E;&#x597D;&#x7684;</td>
</tr>
</tbody>
</table>
<p>2.<strong>warning</strong>(title: string, message: string, timer?: number)</p>
<blockquote>
<p>&#x663E;&#x793A;&#x4E00;&#x6761;&#x8B66;&#x544A;&#x6D88;&#x606F;</p>
</blockquote>
<table>
<thead>
<tr>
<th>&#x53C2;&#x6570;</th>
<th>&#x7C7B;&#x578B;</th>
<th>&#x8BE6;&#x60C5;</th>
</tr>
</thead>
<tbody>
<tr>
<td>title</td>
<td>string</td>
<td>&#x6D88;&#x606F;&#x6807;&#x9898;</td>
</tr>
<tr>
<td>message</td>
<td>string</td>
<td>&#x6D88;&#x606F;&#x5185;&#x5BB9;</td>
</tr>
<tr>
<td>timer</td>
<td>number</td>
<td>&#x6D88;&#x606F;&#x663E;&#x793A;&#x65F6;&#x95F4;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x586B;&#x90A3;&#x4E48;&#x9ED8;&#x8BA4;&#x91C7;&#x7528;&#x5168;&#x5C40;&#x914D;&#x7F6E;&#x7684;forRoot&#x4E2D;&#x8BBE;&#x7F6E;&#x597D;&#x7684;</td>
</tr>
</tbody>
</table>
<p>3.<strong>danger</strong>(title: string, message: string, timer?: number)</p>
<blockquote>
<p>&#x663E;&#x793A;&#x4E00;&#x6761;&#x5371;&#x9669;&#x6D88;&#x606F;</p>
</blockquote>
<table>
<thead>
<tr>
<th>&#x53C2;&#x6570;</th>
<th>&#x7C7B;&#x578B;</th>
<th>&#x8BE6;&#x60C5;</th>
</tr>
</thead>
<tbody>
<tr>
<td>title</td>
<td>string</td>
<td>&#x6D88;&#x606F;&#x6807;&#x9898;</td>
</tr>
<tr>
<td>message</td>
<td>string</td>
<td>&#x6D88;&#x606F;&#x5185;&#x5BB9;</td>
</tr>
<tr>
<td>timer</td>
<td>number</td>
<td>&#x6D88;&#x606F;&#x663E;&#x793A;&#x65F6;&#x95F4;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x586B;&#x90A3;&#x4E48;&#x9ED8;&#x8BA4;&#x91C7;&#x7528;&#x5168;&#x5C40;&#x914D;&#x7F6E;&#x7684;forRoot&#x4E2D;&#x8BBE;&#x7F6E;&#x597D;&#x7684;</td>
</tr>
</tbody>
</table>
<p>4.<strong>success</strong>(title: string, message: string, timer?: number)</p>
<blockquote>
<p>&#x663E;&#x793A;&#x4E00;&#x6761;&#x6210;&#x529F;&#x6D88;&#x606F;</p>
</blockquote>
<table>
<thead>
<tr>
<th>&#x53C2;&#x6570;</th>
<th>&#x7C7B;&#x578B;</th>
<th>&#x8BE6;&#x60C5;</th>
</tr>
</thead>
<tbody>
<tr>
<td>title</td>
<td>string</td>
<td>&#x6D88;&#x606F;&#x6807;&#x9898;</td>
</tr>
<tr>
<td>message</td>
<td>string</td>
<td>&#x6D88;&#x606F;&#x5185;&#x5BB9;</td>
</tr>
<tr>
<td>timer</td>
<td>number</td>
<td>&#x6D88;&#x606F;&#x663E;&#x793A;&#x65F6;&#x95F4;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x586B;&#x90A3;&#x4E48;&#x9ED8;&#x8BA4;&#x91C7;&#x7528;&#x5168;&#x5C40;&#x914D;&#x7F6E;&#x7684;forRoot&#x4E2D;&#x8BBE;&#x7F6E;&#x597D;&#x7684;</td>
</tr>
</tbody>
</table>
<p>5.<strong>create</strong>(
    title: string, 
    message: string, 
    options: { color: string, icon: string, timeout?: number }
)</p>
<blockquote>
<p>&#x663E;&#x793A;&#x4E00;&#x6761;&#x81EA;&#x5B9A;&#x4E49;&#x914D;&#x7F6E;&#x7684;&#x6D88;&#x606F;</p>
</blockquote>
<table>
<thead>
<tr>
<th>&#x53C2;&#x6570;</th>
<th>&#x7C7B;&#x578B;</th>
<th>&#x8BE6;&#x60C5;</th>
</tr>
</thead>
<tbody>
<tr>
<td>title</td>
<td>string</td>
<td>&#x6D88;&#x606F;&#x6807;&#x9898;</td>
</tr>
<tr>
<td>message</td>
<td>string</td>
<td>&#x6D88;&#x606F;&#x5185;&#x5BB9;</td>
</tr>
<tr>
<td>options</td>
<td>Object</td>
<td>&#x76F8;&#x5173;&#x914D;&#x7F6E;&#x53C2;&#x6570;,color&#x4E3A;&#x6D88;&#x606F;&#x7684;&#x989C;&#x8272;&#x6837;&#x5F0F;&#x7C7B;&#x5982;&apos;border-info&apos;,icon&#x8981;&#x663E;&#x793A;&#x7684;&#x4E3A;&#x56FE;&#x6807;&#x6837;&#x5F0F;&#xFF0C;timeout&#x4E3A;&#x663E;&#x793A;&#x65F6;&#x95F4;</td>
</tr>
</tbody>
</table>
<p>&#x7528;&#x4F8B;</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">this</span>.toast.create(
    <span class="hljs-string">&apos;&#x81EA;&#x5B9A;&#x4E49;&#x6D88;&#x606F;&apos;</span>,
    <span class="hljs-string">&apos;&#x8FD9;&#x662F;&#x4E00;&#x6761;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x6D88;&#x606F;&#xFF0C;&#x989C;&#x8272;&#x6837;&#x5F0F;&#x56FE;&#x56FE;&#x6807;&#x90FD;&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&apos;</span>,
    {
        color: <span class="hljs-string">&apos;border-dark&apos;</span>,
        icon: <span class="hljs-string">&apos;fa-user text-dark&apos;</span>,
        timeout: <span class="hljs-number">-1</span>, <span class="hljs-comment">// -1&#x4E3A;&#x6C38;&#x4E0D;&#x6D88;&#x5931;</span>
    }
);
</code></pre>
<p><img src="images/toast.png" alt="&#x81EA;&#x5B9A;&#x4E49;&#x6D88;&#x606F;"></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="CHECKBOX.html" class="navigation navigation-prev " aria-label="Previous page: 单选与多选">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="CONFIRM.html" class="navigation navigation-next " aria-label="Next page: 确认对话框">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"消息提示","level":"4.1","depth":1,"next":{"title":"确认对话框","level":"4.2","depth":1,"path":"CONFIRM.md","ref":"CONFIRM.md","articles":[]},"previous":{"title":"单选与多选","level":"3.1","depth":1,"path":"CHECKBOX.md","ref":"CHECKBOX.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"TOAST.md","mtime":"2018-09-27T06:24:16.591Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-12-08T02:14:36.809Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

